﻿/*
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*/
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;

namespace Scaffold.Views
{
    public class ListViewData<T> 
    {
        public IEnumerable<T> Items { get; set; }
        public int PageIndex { get; set; }
        public int PageSize { get; set; }
        public int ItemCount { get; set; }
        public string Sort { get; set; }
        public string Direction { get; set; }
		public int FirstItem
		{
			get { return PageIndex * PageSize; }
		}
		public int LastItem
		{
			get { return PageIndex * (PageSize+1) - 1; }
		}

        public int PageCount
        {
            get
            {
                return Convert.ToInt32(Math.Ceiling(Convert.ToDouble(ItemCount) / Convert.ToDouble(PageSize)));
            }
        }
    }
}
